From: Felix Fietkau Date: Mon, 20 Oct 2025 17:43:27 +0000 (+0200) Subject: system-linux: handle RTM_DELLINK events for device state tracking X-Git-Url: http://git.openwrt.org/%22http:/oss.oetiker.ch/rrdtool//%22/%22http:/oss.oetiker.ch/rrdtool/%22?a=commitdiff_plain;h=b6d371f307705b32e1ef5c63d7bf6440c8859789;p=project%2Fnetifd.git system-linux: handle RTM_DELLINK events for device state tracking Add RTM_DELLINK handling to properly track device lifecycle. When a device is deleted, update its state with flags=0 to mark it as not present. This improves synchronization compared to only relying on the hotplug handler. Signed-off-by: Felix Fietkau --- diff --git a/system-linux.c b/system-linux.c index 6582535..ceeabe3 100644 --- a/system-linux.c +++ b/system-linux.c @@ -732,8 +732,9 @@ static int cb_rtnl_event(struct nl_msg *msg, void *arg) struct ifinfomsg *ifi = NLMSG_DATA(nh); struct nlattr *nla[__IFLA_MAX]; struct device *dev; + unsigned int flags; - if (nh->nlmsg_type != RTM_NEWLINK) + if (nh->nlmsg_type != RTM_NEWLINK && nh->nlmsg_type != RTM_DELLINK) return 0; nlmsg_parse(nh, sizeof(struct ifinfomsg), nla, __IFLA_MAX - 1, NULL); @@ -744,7 +745,8 @@ static int cb_rtnl_event(struct nl_msg *msg, void *arg) if (!dev) return 0; - system_device_update_state(dev, ifi->ifi_flags); + flags = (nh->nlmsg_type == RTM_DELLINK) ? 0 : ifi->ifi_flags; + system_device_update_state(dev, flags); return 0; }